package org.yh.leetcode;

import java.util.LinkedList;

/**
 * @Author: yh
 * @Description:
 * @Date: Created in 17:44 2019/5/13
 * @Modified By:
 */
public class Test6 {
    //判断一个数是否是回文数
    public boolean isPalindrome(int x) {
        boolean flag = false;
        int temp = x;
        if (x < 0) {
            return flag;
        }
        LinkedList<Integer> linkedList = new LinkedList<Integer>();
        while (x != 0) {
            linkedList.add(x % 10);
            x /= 10;
        }
        int len = linkedList.size();
        Double sum = 0d;
        for (int i = 0; i < len; i++) {
            sum += linkedList.get(i) * Math.pow(10, len - 1 - i);
        }
        if (sum == temp) {
            flag = true;
        }
        return flag;
    }

    public static void main(String[] args) {
        Test6 test6 = new Test6();
        System.out.println(Integer.MAX_VALUE);
        boolean palindrome = test6.isPalindrome(2147483647);
        System.out.println("结果：" + palindrome);
    }
}
